<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\Model\Message;
use app\admin\Model\Banner as Ban;
use app\admin\Model\Pay;
use think\Db;
use app\admin\validate\Stu as qbc;

class Banner extends Common
{
	
	public function list(){
		
		$list = Ban::paginate(4);
		$page = $list->render();
	     //halt($list);
		
		return $this->fetch('list',['list'=>$list,'page'=>$page]);
	}
	public function add(){
		$ban = new Ban();
			
		if(input("?param.sub")){
			
			
			$result = $ban->add();
			if($result){
				$this->success("添加成功","banner/list");
			}else{
				$this->error("添加失败");
			}
		}else{
			return $this->fetch("add",[]);
		}
	}
	public function upda($id=''){
		$ss = new Ban();
		$validate = new qbc();
		if(request()->isPost())
		{		
				$file = request()->file('photo');
					if($file)
					{
							$result = $validate->check($_POST);
							if(!$result)
							{
								echo $validate->getError();
								exit;
							 }
							 $quest=$ss->up1xiu($file);
							
					}
					else{
							$result = $validate->check($_POST);
							if(!$result)
							{
								echo $validate->getError();
								exit;
							 }
							 $quest=$ss->up1();		
						
					}
					 if($quest)
							{
								$this->success('成功','banner/list');
							}
							else{
								$this->success('shibai');
							}
		}
		else{
				$ss= new Ban();
				$id = input('param.b_id');
    	
    	         $quest = Ban::get($id);
				//$quest=$ss->acs($id);
				
				return view('update',['quest'=>$quest]);
		}
	}

}
?>